package com.tiza.xiaoyoubao.ui.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;

import com.orhanobut.hawk.Hawk;
import com.tianze.library.base.BaseFragment;
import com.tiza.xiaoyoubao.R;
import com.tiza.xiaoyoubao.app.Constants;
import com.tiza.xiaoyoubao.entity.BrowseCompleteInfo;
import com.tiza.xiaoyoubao.entity.BrowseConfirmInfo;
import com.tiza.xiaoyoubao.entity.BrowseDnTaskOrderInfo;
import com.tiza.xiaoyoubao.entity.BrowseOperateInfo;
import com.tiza.xiaoyoubao.entity.TaskOrderInfo;
import com.tiza.xiaoyoubao.utils.DateUtils;

import butterknife.BindView;

/**
 * Created by mapple on 17/4/14.
 * 手机浏览任务详情2
 */

public class BrowseDnTaskDetail2Fragment extends BaseFragment {

    @BindView(R.id.tv_shopName)
    TextView tv_shopName;
    @BindView(R.id.tv_shopDescribe)
    TextView tv_shopDescribe;
    @BindView(R.id.tv_keyWord)
    TextView tv_keyWord;
    @BindView(R.id.tv_showPrice)
    TextView tv_showPrice;
    @BindView(R.id.tv_taskType)
    TextView tv_taskType;
    @BindView(R.id.tv_receiving)
    TextView tv_receiving;
    @BindView(R.id.tv_location)
    TextView tv_location;
    @BindView(R.id.tv_city)
    TextView tv_city;
    @BindView(R.id.tv_priceInterval)
    TextView tv_priceInterval;
    @BindView(R.id.tv_additionalRequest)
    TextView tv_additionalRequest;

    private BrowseDnTaskOrderInfo browseDnTaskOrderInfo;
    private BrowseCompleteInfo browseCompleteInfo;
    private BrowseOperateInfo browseOperateInfo;
    private BrowseConfirmInfo browseConfirmInfo;
    Bundle args;
    private String state;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        args = getArguments();
        state = args.getString("state");
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_browse_dn_task_detail2;
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        switch (state) {
            case "browseOperate":
                BrowseConfirm();
                break;
            case "confirm":
                BrowseOperate();
                break;
            case "browseComplate":
                BrowseComplate();
                break;
            case "browseDnTb":
                BrowseDnTb();
                break;
            default:
                break;
        }

    }

    public void BrowseComplate() {
        browseCompleteInfo = (BrowseCompleteInfo) args.getSerializable("info");
        tv_shopName.setText(browseCompleteInfo.getShopName());
        tv_shopDescribe.setText(browseCompleteInfo.getTitle());
        tv_showPrice.setText(browseCompleteInfo.getMobilePrice());
        tv_taskType.setText(browseCompleteInfo.getTypeName());
        tv_keyWord.setText(browseCompleteInfo.getKeywords());
        tv_city.setText(browseCompleteInfo.getCity());
        tv_receiving.setText(browseCompleteInfo.getReceiving());
        if (browseCompleteInfo.getLocation().equals("xiaoliang")) {
            tv_location.setText("销量");
        } else if (browseCompleteInfo.getLocation().equals("zhitongche")) {
            tv_location.setText("直通车");
        } else if (browseCompleteInfo.getLocation().equals("zonghe")) {
            tv_location.setText("综合");
        }
        tv_priceInterval.setText(browseCompleteInfo.getPriceSection());
        if (browseCompleteInfo.getRemarks().equals(" ")) {
            tv_additionalRequest.setText("商家要求:此商家无其他要求");
        } else {
            tv_additionalRequest.setText("商家要求:" + browseCompleteInfo.getRemarks());
        }
    }

    public void BrowseOperate() {
        browseOperateInfo = (BrowseOperateInfo) args.getSerializable("info");
        tv_shopName.setText(browseOperateInfo.getShopName());
        tv_shopDescribe.setText(browseOperateInfo.getTitle());
        tv_showPrice.setText(browseOperateInfo.getMobilePrice());
        tv_taskType.setText(browseOperateInfo.getTypeName());
        tv_keyWord.setText(browseOperateInfo.getKeywords());
        tv_city.setText(browseOperateInfo.getCity());
        tv_receiving.setText(browseOperateInfo.getReceiving());
        if (browseOperateInfo.getLocation().equals("xiaoliang")) {
            tv_location.setText("销量");
        } else if (browseOperateInfo.getLocation().equals("zhitongche")) {
            tv_location.setText("直通车");
        } else if (browseOperateInfo.getLocation().equals("zonghe")) {
            tv_location.setText("综合");
        }
        tv_priceInterval.setText(browseOperateInfo.getPriceSection());
        if (browseOperateInfo.getRemarks().equals(" ")) {
            tv_additionalRequest.setText("商家要求:此商家无其他要求");
        } else {
            tv_additionalRequest.setText("商家要求:" + browseOperateInfo.getRemarks());
        }
    }

    public void BrowseConfirm() {
        browseConfirmInfo = (BrowseConfirmInfo) args.getSerializable("info");
        tv_shopName.setText(browseConfirmInfo.getShopName());
        tv_shopDescribe.setText(browseConfirmInfo.getTitle());
        tv_showPrice.setText(browseConfirmInfo.getMobilePrice());
        tv_taskType.setText(browseConfirmInfo.getTypeName());
        tv_keyWord.setText(browseConfirmInfo.getKeywords());
        tv_receiving.setText(browseConfirmInfo.getReceiving());
        tv_city.setText(browseConfirmInfo.getCity());
        tv_priceInterval.setText(browseConfirmInfo.getPriceSection());
        if (browseConfirmInfo.getLocation().equals("xiaoliang")) {
            tv_location.setText("销量");
        } else if (browseConfirmInfo.getLocation().equals("zhitongche")) {
            tv_location.setText("直通车");
        } else if (browseConfirmInfo.getLocation().equals("zonghe")) {
            tv_location.setText("综合");
        }
        if (browseConfirmInfo.getRemarks().equals(" ")) {
            tv_additionalRequest.setText("商家要求:此商家无其他要求");
        } else {
            tv_additionalRequest.setText("商家要求:" + browseConfirmInfo.getRemarks());
        }
    }

    public void BrowseDnTb() {
        browseDnTaskOrderInfo = (BrowseDnTaskOrderInfo) args.getSerializable("info");
        tv_shopName.setText(browseDnTaskOrderInfo.getShopName());
        tv_shopDescribe.setText(browseDnTaskOrderInfo.getTitle());
        tv_showPrice.setText(browseDnTaskOrderInfo.getMobilePrice());
        tv_taskType.setText(browseDnTaskOrderInfo.getTypeName());
        tv_keyWord.setText(browseDnTaskOrderInfo.getKeywords());
        tv_city.setText(browseDnTaskOrderInfo.getCity());
        tv_receiving.setText(browseDnTaskOrderInfo.getReceiving());
        if (browseDnTaskOrderInfo.getLocation().equals("xiaoliang")) {
            tv_location.setText("销量");
        } else if (browseDnTaskOrderInfo.getLocation().equals("zhitongche")) {
            tv_location.setText("直通车");
        } else if (browseDnTaskOrderInfo.getLocation().equals("zonghe")) {
            tv_location.setText("综合");
        }
        tv_priceInterval.setText(browseDnTaskOrderInfo.getPriceSection());
        if (browseDnTaskOrderInfo.getRemarks().equals(" ")) {
            tv_additionalRequest.setText("商家要求:此商家无其他要求");
        } else {
            tv_additionalRequest.setText("商家要求:" + browseDnTaskOrderInfo.getRemarks());
        }
    }
}
